@layout("/common/_container.html",{js:["/assets/modular/system/task/projectTaskAdmin.js"]}){
<style>
    .btnshop {
        display: inline-block;
        height: 38px;
        line-height: 38px;
        padding: 0 18px;
        background-color: #009688;
        color: #fff;
        white-space: nowrap;
        text-align: center;
        font-size: 14px;
        border: none;
        border-radius: 2px;
        cursor: pointer;
        margin-bottom: 10px;
    }
    .yq{
        border-color: #D2D2D2;
        width: 100%;
        height: 40px;
        padding-left: 10px;
        padding-top: 10px;
    }
    .btnYg{
        border-color: #FFFFFF;
        background-color: #FFFFFF;
    }
</style>
<div class="layui-body-header">
    <span class="layui-body-header-title">添加</span>
</div>

<div class="layui-fluid " style="">
    <div class="layui-card">
        <div class="layui-card-body">

            <form id="taskForm" lay-filter="taskForm" class="layui-form model-form"
                  style="max-width: 700px;margin: 40px auto;">
                <input name="id" id="proId" type="hidden" value="${id}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-block">
                        <input type="button" class="btnshop" id="scouting" name="Submit" value="现场踏勘"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label name">出图日期</label>
<!--                    <div class="layui-input-block">-->
                    <div class="layui-inline" style="display: flex;flex-direction: row">
                    <input id="plotData" name="plotData" placeholder="请选择时间" type="text"
                               class="layui-input msg sj" autocomplete="off"/>
                        <input class="taskId" value="31" hidden>
<!--                        <input class="btnshop" type="button" value="提交" style="width: 70px;margin-left: 10px;"-->
<!--                               id="ct">-->
                        <div class="btnYg"  value="" style="margin-left: 10px;width: 78px;display: contents;" >
                        </div>
                        <input class="btnshop editCt" type="button" value="修改" style="width: 70px;margin-left: 10px;display: none"
                               id="31">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label name">开工日期</label>
<!--                    <div class="layui-input-block">-->
                    <div class="layui-inline" style="display: flex;flex-direction: row">
                    <input id="startData" name="startData" placeholder="请选择时间" type="text"
                               class="layui-input msg sj" autocomplete="off"/>
                        <input class="taskId" value="32" hidden>
<!--                        <input class="btnshop" type="button" value="提交" style="width: 70px;margin-left: 10px;"-->
<!--                               id="kg">-->
                        <div class="btnYg"  value="" style="margin-left: 10px;width: 78px;display: contents;" >
                        </div>
                        <input class="btnshop editKg" type="button" value="修改" style="width: 70px;margin-left: 10px;display: none"
                               id="32">
                    </div>
                </div>
<!--                if(shiro.hasPermission("/project/gcyqxxgsj")){-->
                <div class="layui-form-item" id="noteRemark">
                    <label class="layui-form-label gf name">工程已逾期，请填写原因：</label>
                    <div class="layui-inline" style="display: flex;flex-direction: row">
                        <textarea name="note" id="note" cols="30" rows="10"  placeholder="请填写原因" lay-filter="note" class="yq"></textarea>
<!--                        <div class="btnYg"  value="" style="margin-left: 10px;width: 78px;display: contents;" >-->
<!--                        </div>-->
                        <div class="btnYg editCt" type="button" value="修改" style="width: 70px;margin-left: 10px;"></div>

                        <!--                        <input name="note" id="note" style="padding-top: 10px;width: 85%;"-->
                        <!--                               class="msg" autocomplete="off" placeholder="请填写原因" lay-filter="note">-->
                    </div>
                </div>
<!--                }-->
                <div class="layui-form-item">
                    <label class="layui-form-label name">预估完工日期</label>
                    <div class="layui-inline" style="display: flex;flex-direction: row" id="canChange">
                        <input id="predictData" name="predictData" type="text"
                               class="layui-input msg sj" autocomplete="off" disabled="disabled"/>
                        <input class="taskId" value="33" hidden>
                        <div class="btnYg"  value="" style="margin-left: 10px;width: 78px;display: contents;" >
                        </div>
                        <div class="btnYg editCt" type="button" value="修改" style="width: 70px;margin-left: 10px;"
                        >
                        </div>
                    </div>
                </div>
                <!--                实际完工日期-->
                <div class="layui-form-item">
                    <label class="layui-form-label name">交店日期</label>
<!--                    <div class="layui-input-block">-->
                    <div class="layui-inline" style="display: flex;flex-direction: row">

                    <input id="actualData" name="actualData" placeholder="请选择时间" type="text"
                               class="layui-input msg sj" autocomplete="off"/>
                        <input class="taskId" value="34" hidden>
<!--                        <input class="btnshop" type="button" value="提交" style="width: 70px;margin-left: 10px;"-->
<!--                               id="jd">-->
                        <div class="btnYg"  value="" style="margin-left: 10px;width: 78px;display: contents;" >
                        </div>
                        <div class="btnYg editCt" type="button" value="修改" style="width: 70px;margin-left: 10px;"
                        >
                        <input class="btnshop editJd" type="button" value="修改" style="width: 70px;margin-left: 10px;display: none"
                               id="34">
                    </div>
                </div>
                <!--                <div class="layui-form-item">-->
                <!--                    <label class="layui-form-label name">交店日期</label>-->
                <!--                    <div class="layui-input-block">-->
                <!--                        <input id="jiaodian" name="jiaodian" placeholder="请选择时间" type="text"-->
                <!--                               class="layui-input msg sj" autocomplete="off"/>-->
                <!--                        <input class="taskId" value="35" hidden>-->
                <!--                    </div>-->
                <!--                </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;"></label>
                    <div class="layui-input-block">
<!--                        if(shiro.hasPermission("/project/gcbc")){-->
<!--                        <a class="layui-btn btnshop" lay-filter="btnSubmit" lay-submit style="margin-bottom: 10px"-->
<!--                           id="btnSubmit">&emsp;提交&emsp;-->
<!--                        </a>-->
<!--                        }-->
                        <a class="layui-btn btnshop" lay-filter="btnSubmit" lay-submit style="margin-bottom: 10px"
                           id="btnSubmit">&emsp;提交&emsp;
                        </a>
                        <button class="layui-btn layui-btn-primary" type="button" id="backupPage"
                                style="margin-bottom: 10px">&emsp;返回&emsp;
                        </button>
                    </div>
                </div>
                 </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="https://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="application/javascript">
    const id = '${id}';
    const list = [${list}];
    var _list = list[0][0]

    function handleList(_id) {
        let obj = null;
        _list.map((item, index) => {
            if(item.taskId ==  _id) {
                obj = item
            }
        });
        return obj
    }
    console.log(_list);

    $(function () {

        // 编辑按钮默认不显示
        var infoA = [31];//出图日期
        var infoB = [32];//开工日期
        var infoC = [34];//交店日期

        // 第一个修改 默认不显示
        let hideBtnEditA = true;
        // 第二个修改 默认不显示
        let hideBtnEditB = true;
        // 第三个修改 默认不显示
        let hideBtnEditC = true;

        $("#proId").val(id);
        $(".name").each(function (o, e) {
            // let taskId = list[0][0][i].taskId;
            let _taskId = $(e).next().find('.taskId').val();
            var _param = handleList(_taskId);
            if (_taskId == "33") {
                $("#note").val( _param.note);
            }
            if (_param && _param.content != null && _param.content != '') {
                $(e).next().find('.msg').val(_param.content);
                // $(e).next().find('.msg').attr("readonly", "true");
                // $(e).next().find('.sj').removeAttr('id');
                // 出图日期
                if($.inArray(Number(_taskId), infoA) != -1) {
                    hideBtnEditA = false;
                    console.log(1111)
                }
                // 开工日期
                if($.inArray(Number(_taskId), infoB) != -1) {
                    hideBtnEditB = false
                }
                // 交店日期
                if($.inArray(Number(_taskId), infoC) != -1) {
                    hideBtnEditC = false
                }
            }
        });
        // 出图
        if(!hideBtnEditA) {
            $('#ct').hide();
            $('.editCt').css("display","block");
            console.log(2222)
        } else {
            $('.editCt').css("display","none");
            console.log(233333)
        }
        // 开工
        if(!hideBtnEditB) {
            $('#kg').hide();
            $('.editKg').css("display","block");
        } else {
            $('.editKg').css("display","none");
        }
        // 交店
        if(!hideBtnEditC) {
            $('#jd').hide();
            $('.editJd').css("display","block");
        } else {
            $('.editJd').css("display","none");
        }

        // $("#proId").val(id);
        // for (let i = 0; i < list[0][0].length; i++) {
        //     $(".name").each(function (o, e) {
        //         let taskId = list[0][0][i].taskId;
        //         if (taskId == $(e).next().find('.taskId').val() && list[0][0][i].content != null && list[0][0][i].content != "") {
        //             $(e).next().find('.msg').val(list[0][0][i].content);
        //             $(e).next().find('.msg').attr("readonly", "true");
        //             $(e).next().find('.sj').removeAttr('id');
        //         }
        //     });
        // }
    });
</script>
@}


















